package com.xmx.controller;

import com.xmx.entity.CrmUsers;
import com.xmx.service.ICrmUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Map;

/**
 * overview：
 * author:
 * 2023年05月04日 14:05:
 */
@Controller
public class loginController {
    @Autowired
    private ICrmUsersService iCrmUsersService;


    @RequestMapping("/queryUserByConditions")
    public String queryUserByConditions(HttpSession session,CrmUsers crmUsers){
        System.out.println("进入到控制器的");
        CrmUsers users = iCrmUsersService.queryUserBy(crmUsers);
        System.out.println("得到的对象："+users);
        if(users!=null && !"".equals(users)){//匹配
            String username = users.getUsername();
            System.out.println("得到的用户名对象："+username);
            session.setAttribute("username", username);//保存用户名到session
            return "redirect:page_Main";
        }
        return "redirect:page_login";
    }
    //退出登录
    @RequestMapping("/outLogin")
    public String outLogin(HttpSession session){
        session.removeAttribute("username");
        return "redirect:page_login";
    }
}
